package com.yuexunit.operationman.nbsy.module.SafeOperation.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.SafeOperation.bean.SafeOperationBean;
import com.yuexunit.operationman.nbsy.module.SafeOperation.ui.Act_SafeOperation_Preview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by work-jx on 2017/7/11.
 */
public class Fragment_SO_BeforeLeave extends KJFragment {
    @Bind(R.id.frag_so_bl_tv_01)
    TextView fragSoBlTv01;
    @Bind(R.id.frag_so_bl_tv_02)
    TextView fragSoBlTv02;
    @Bind(R.id.frag_so_bl_tv_03)
    TextView fragSoBlTv03;
    @Bind(R.id.frag_so_bl_tv_04)
    TextView fragSoBlTv04;
    @Bind(R.id.frag_so_bl_tv_05)
    TextView fragSoBlTv05;
    @Bind(R.id.frag_so_bl_tv_06)
    TextView fragSoBlTv06;
    @Bind(R.id.frag_so_bl_tv_07)
    TextView fragSoBlTv07;
    @Bind(R.id.frag_so_bl_tv_08)
    TextView fragSoBlTv08;
    @Bind(R.id.frag_so_bl_tv_09)
    TextView fragSoBlTv09;
    private Act_SafeOperation_Preview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        aty = (Act_SafeOperation_Preview) getActivity();
        mMainView = layoutInflater.inflate(R.layout.fragment_so_beforeleave, viewGroup, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    @Override
    protected void initData() {
        for(SafeOperationBean.ObjectEntity.SecurityItemListEntity p : AppConfig.SAFEOPERATIONBEAN.getObject().getSecurityItemList()){
            switch (p.getItemCode())
            {
                case "BL_HuanZheXinXi":
                    if(p.getItemValue().equals("1"))
                    {
                        fragSoBlTv01.setText("是");
                    }
                    else if (p.getItemValue().equals("0")){
                        fragSoBlTv01.setText("否");
                    }
                    break;
                case "BL_ShiJiShouShuFangShi":
                    if(p.getItemValue().equals("1"))
                    {
                        fragSoBlTv02.setText("是");
                    }
                    else if (p.getItemValue().equals("0")){
                        fragSoBlTv02.setText("否");
                    }
                    break;
                case "BL_ShouShuYongYaoShuXue":
                    if(p.getItemValue().equals("1"))
                    {
                        fragSoBlTv03.setText("是");
                    }
                    else if (p.getItemValue().equals("0")){
                        fragSoBlTv03.setText("否");
                    }
                    break;
                case "BL_ShouShuYongWuQingDian":
                    if(p.getItemValue().equals("1"))
                    {
                        fragSoBlTv04.setText("是");
                    }
                    else if (p.getItemValue().equals("0")){
                        fragSoBlTv04.setText("否");
                    }
                    break;
                case "BL_ShouShuBiaoBen":
                    if(p.getItemValue().equals("1"))
                    {
                        fragSoBlTv05.setText("是");
                    }
                    else if (p.getItemValue().equals("0")){
                        fragSoBlTv05.setText("否");
                    }
                    break;
                case "BL_PiFuWangZheng":
                    if(p.getItemValue().equals("1"))
                    {
                        fragSoBlTv06.setText("是");
                    }
                    else if (p.getItemValue().equals("0")){
                        fragSoBlTv06.setText("否");
                    }
                    break;
                case "BL_GeZhongGuanLu":
                    if(p.getItemValue().length()>0)
                    {
                        String[]array = p.getItemValue().split(";");
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.safeoperation_bl_01);
                        for (int i = 0; i < array.length; i++) {
                            switch (array[i]) {
                                case "1":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[0];
                                    }
                                    else {
                                        content += arrays[0];
                                    }
                                    break;
                                case "2":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[1];
                                    }
                                    else {
                                        content += arrays[1];
                                    }
                                    break;
                                case "3":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[2];
                                    }
                                    else {
                                        content += arrays[2];
                                    }
                                    break;
                                case "4":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[3];
                                    }
                                    else {
                                        content += arrays[3];
                                    }
                                    break;
                                case "5":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[4];
                                    }
                                    else {
                                        content += arrays[4];
                                    }
                                    break;
                                case "6":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[5];
                                    }
                                    else {
                                        content += arrays[5];
                                    }
                                    break;
                                case "7":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[6];
                                    }
                                    else {
                                        content += arrays[6];
                                    }
                                    break;
                            }
                        }
                        fragSoBlTv07.setText(content);
                    }
                    break;
                case "BL_HuanZheQuXiang":
                    if(p.getItemValue().length()>0)
                    {
                        String[]array = p.getItemValue().split(";");
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.safeoperation_bl_02);
                        for (int i = 0; i < array.length; i++) {
                            switch (array[i]) {
                                case "1":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[0];
                                    }
                                    else {
                                        content += arrays[0];
                                    }
                                    break;
                                case "2":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[1];
                                    }
                                    else {
                                        content += arrays[1];
                                    }
                                    break;
                                case "3":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[2];
                                    }
                                    else {
                                        content += arrays[2];
                                    }
                                    break;
                                case "4":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[3];
                                    }
                                    else {
                                        content += arrays[3];
                                    }
                                    break;
                            }
                        }
                        fragSoBlTv08.setText(content);
                    }
                    break;
                case "BL_Other":
                    fragSoBlTv09.setText(p.getItemValue());
                    break;
            }
        }
    }
}
